import 'dart:async';
import 'dart:convert';

import 'package:barcode_scan/barcode_scan.dart';
import 'package:charts_flutter/flutter.dart' as charts;
import 'package:date_format/date_format.dart';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_hotwork/Myapplication.dart';
import 'package:flutter_hotwork/baobiao/JieSuanBaoBiao.dart';
import 'package:flutter_hotwork/baobiao/TimeBaobiao.dart';
import 'package:flutter_hotwork/baobiao/TongJiBaoBiao.dart';
import 'package:flutter_hotwork/bean/BaseBean.dart';
import 'package:flutter_hotwork/bean/GetDayMonthTotalFlowVoBean.dart';
import 'package:flutter_hotwork/bean/GetLineAndHotUserTreeVoBean.dart';
import 'package:flutter_hotwork/bean/HotLineBean.dart';
import 'package:flutter_hotwork/bean/UserTaskBean.dart';
import 'package:flutter_hotwork/bean/hotuserinfobean.dart';
import 'package:flutter_hotwork/bean/hotuserleijiliuliangbean.dart';
import 'package:flutter_hotwork/bean/userInfoList.dart';
import 'package:flutter_hotwork/fuheyuce/FuHeYuCe.dart';
import 'package:flutter_hotwork/home/messagecenter/MessageCenterAct.dart';
import 'package:flutter_hotwork/homepage/BaseTitleBar.dart';
import 'package:flutter_hotwork/homepage/BaseViewBar.dart';
import 'package:flutter_hotwork/hotuserlist/HotUserData2.dart';
import 'package:flutter_hotwork/hotuserlist/HotUserInfoAct.dart';
import 'package:flutter_hotwork/lishiquxian/HistoryLine.dart';
import 'package:flutter_hotwork/tradeamount/TradeAmount.dart';
import 'package:flutter_hotwork/utils/DioUtils.dart';
import 'package:flutter_hotwork/utils/LogUtil.dart';
import 'package:flutter_hotwork/yongliang/YongHuYongLiangShenBao.dart';
import 'package:logger/logger.dart';

import '../Login.dart';
import '../Toast.dart';
import 'RoadChoice3.dart';
import 'messagecenter/HotUserMessageCenter.dart';

class HomeScreen extends StatefulWidget {
  @override
  HomeScreenState createState() => HomeScreenState();
}

const searchList = [
  '最新采集时间',
  '阀后温度',
  '瞬时流量',
  '工作温度',
  '工作压力',
  '数据',
];

const recentSuggest = [
  '最新采集时间',
  '阀后温度',
  '瞬时流量',
  '工作温度',
  '工作压力',
  '数据',
];
var id = "1";
var userid = 50000;
var time = formatDate(
    new DateTime.now(), [yyyy, '-', mm, '-', dd, "  ", HH, ":", nn, ":", ss]);
var gongzuowendu = 0.0; //工作温度
var fahouwendu = 0.0;
var gongzuoyali = 0.0; //工作压力
var diandongfa = 0; //电动阀
var shuju = 0; //数据
var tongxun = 0; //通讯
var baojing = 0; //报警
var shunshiliuliang = 0.0; //瞬时流量
var leijiliuliang = 0.0;
var shengyuqiliang = 0.0; //剩余气量
var hotusercount = 0;

var firstrefresh = 0;
var chartdata = 0;
var initarea = "";

var totaltask = 0;
var successtask = 0;
var fitertask = 0;
HotLineBean hotLineBean = new HotLineBean();
UserTaskBean userTaskBean = new UserTaskBean();
hotuserinfobean userinfobean = new hotuserinfobean();
GetDayMonthTotalFlowVoBean getDayMonthTotalFlowVoBean;
Timer mtimer;

class SeriesDatas {
  final int X;
  final double Y;

  SeriesDatas(this.X, this.Y);
}

List<SeriesDatas> data1() {
  List<SeriesDatas> listdata = new List<SeriesDatas>();
  if (null != hotLineBean.result) {
    for (int i = 0; i < hotLineBean.result.length; i++) {
      //
      SeriesDatas data = new SeriesDatas(i, hotLineBean.result[i].supplyHeat);
      // SeriesDatas data=new SeriesDatas("", quxianbean.result[0].lists[i].jobTemperature);
      // SeriesDatas data=new SeriesDatas(quxianbean.result[0].lists[i].createTime, quxianbean.result[0].lists[i].jobTemperature);
      listdata.add(data);
    }
  }
  return listdata;
}

List<SeriesDatas> data2() {
  List<SeriesDatas> listdata = new List<SeriesDatas>();
  if (null != hotLineBean.result) {
    for (int i = 0; i < hotLineBean.result.length; i++) {
      //
      SeriesDatas data = new SeriesDatas(i, hotLineBean.result[i].sellHot);
      // SeriesDatas data=new SeriesDatas("", quxianbean.result[0].lists[i].jobStress);
      // SeriesDatas data=new SeriesDatas(quxianbean.result[0].lists[i].createTime, quxianbean.result[0].lists[i].jobStress);
      listdata.add(data);
    }
  }
  return listdata;
}

class HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
  Map selectArea;

  @override
  void dispose() {
    super.dispose();
    mtimer.cancel();
    firstrefresh = 0;
  }

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    getShowToast();
    if (MyApplication.loginuserinfo.userInfo.amHotuser == 0) {
      getLineAndHotUserTreeVo();
    }
    getHotUserInfo(id);
    refresh();
  }

  ///接收选择的结果
  void handleSelect(Map targetArea) {
    selectArea = targetArea;
    // initData(selectArea['proviceIndex'], selectArea['cityIndex']);
    id = selectArea['id'];
    getHotUserInfo(id);
    // getHotUserleiji();
  }

  @override
  Widget build(BuildContext context) {
    // if (firstrefresh == 0) {
    //   const timeout = const Duration(seconds: 60);
    //   mtimer = new Timer.periodic(timeout, (mtimer) { //callback function
    //     //1s 回调一次
    //     refresh();
    //     // timer.cancel();  // 取消定时器
    //   });
    // }

    double rpxw = MediaQuery.of(context).size.width / 750;

    // const timeout = const Duration(seconds: 5);
    // print('currentTime='+DateTime.now().toString()); // 当前时间
    // Timer(timeout, () { //callback function
    //   print('afterTimer='+DateTime.now().toString()); // 5s之后
    // });

    return Scaffold(
      appBar: new BaseViewBar(
          childView: new BaseTitleBar(
            "智慧热网管控系统",
            leftIcon: '', //images/saomiao.png
            rightIcon: '',
            rightClick: () {
              print("点击了右边干嘛啊。。。哦");
              showSearch(context: context, delegate: SearchBarDelegate());
            },
            leftClick: () {
              scan();
              print("点击了左边干嘛啊。。。哦");
            },
          ),
          preferredSize: Size.fromHeight(50.0)),
      body: Container(
          color: Colors.grey[200],
          child: firstrefresh >= 0
              ? new CustomScrollView(
                  shrinkWrap: true,
                  // 内容
                  slivers: <Widget>[
                    new SliverPadding(
                      padding: const EdgeInsets.all(0),
                      sliver: new SliverList(
                        delegate: new SliverChildListDelegate(
                          <Widget>[
                            Container(
                              height: 30,
                              color: Colors.white,
                              margin: EdgeInsets.only(
                                  left: 0, right: 0, top: 0, bottom: 5),
                              padding: EdgeInsets.only(
                                  left: 10, right: 0, top: 0, bottom: 0),
                              child: Row(
                                crossAxisAlignment: CrossAxisAlignment.center,
                                children: [
                                  MyApplication.loginuserinfo.userInfo.amHotuser == 0
                                      ? Container(
                                          width: 180,
                                          margin: EdgeInsets.only(
                                              left: 0,
                                              right: 0,
                                              top: 5,
                                              bottom: 5),
                                          child: RaisedButton(
                                            color: Colors.white,
                                            onPressed: () {
                                              showBottomSheet(
                                                  context: context,
                                                  builder: (_) => Container(
                                                        height: 200.0,
                                                        child: AreaSelection3(
                                                          onSelect:
                                                              handleSelect,
                                                          initProviceIndex:
                                                              selectArea == null
                                                                  ? 0
                                                                  : selectArea[
                                                                      'proviceIndex'],
                                                          initCityIndex:
                                                              selectArea == null
                                                                  ? 0
                                                                  : selectArea[
                                                                      'cityIndex'],
                                                          // initCountyIndex: selectArea == null ? 0 : selectArea['countyIndex'],
                                                        ),
                                                      ));
                                            },
                                            child: Text(
                                              selectArea != null
                                                  ? selectArea['address']
                                                  : initarea,
                                              overflow: TextOverflow.ellipsis,
                                            ),
                                          ),
                                        )
                                      : new Container(),
                                  Flexible(
                                      fit: FlexFit.tight, child: SizedBox()),
                                  new Container(
                                    child: new Text(
                                      "$time",
                                      style: TextStyle(
                                          color: const Color(0xFFA4A4A4),
                                          fontSize: 14),
                                    ),
//                      color: Color(0xFFA4A4A4),
                                    margin: const EdgeInsets.only(
                                        left: 0, right: 0, top: 0, bottom: 0),
                                  ),
                                  new Container(
                                    height: 30,
                                    width: 30,
                                    child: IconButton(
                                      onPressed: () => rebuild(),
                                      icon: Image(
                                        fit: BoxFit.fill,
                                        height: 30,
                                        width: 30,
                                        image: AssetImage("images/shuaxin.png"),
                                      ),
                                    ),
                                  ),
                                ],
                              ),
                            ),
                            Container(
                              height: 80,
                              margin: EdgeInsets.all(5),
                              padding: EdgeInsets.only(
                                  left: 10, right: 0, top: 0, bottom: 0),
                              decoration: BoxDecoration(
//                  border: new Border.all(color: Color(0xFF9E9E9E), width: 0.5), // 边色与边宽度
                                color: Colors.white,
                                // 底色
                                //        borderRadius: new BorderRadius.circular((20.0)), // 圆角度
                                borderRadius:
                                    BorderRadius.all(Radius.circular(5)),
                              ),
                              child: Row(
                                mainAxisAlignment: MainAxisAlignment.center,
                                children: [
                                  Container(
                                    width: 80,
                                    child: Column(
                                      mainAxisAlignment:
                                          MainAxisAlignment.center,
//                      textDirection: TextDirection.,
                                      children: [
                                        Text(
                                          "电动阀",
                                          style: TextStyle(
                                              color: const Color(0xFF2B85E4),
                                              fontSize: 16),
                                        ),
                                        Image(
                                          height: 40,
                                          width: 20,
                                          image: AssetImage(diandongfa == 0
                                              ? "images/duankailianjie.png"
                                              : "images/yilianjie.png"),
                                        ),
                                      ],
                                    ),
                                  ),
                                  Container(
                                    width: 80,
                                    child: Column(
                                      mainAxisAlignment:
                                          MainAxisAlignment.center,
                                      children: [
                                        Text(
                                          "数据",
                                          style: TextStyle(
                                              color: const Color(0xFF2B85E4),
                                              fontSize: 16),
                                        ),
                                        Image(
                                          height: 40,
                                          width: 20,
                                          image: AssetImage(shuju == 1
                                              ? "images/duankailianjie.png"
                                              : "images/yilianjie.png"),
                                        ),
                                      ],
                                    ),
                                  ),
                                  Container(
                                    width: 80,
                                    child: Column(
                                      mainAxisAlignment:
                                          MainAxisAlignment.center,
                                      children: [
                                        Text(
                                          "通讯",
                                          style: TextStyle(
                                              color: const Color(0xFF2B85E4),
                                              fontSize: 16),
                                        ),
                                        Image(
                                          height: 40,
                                          width: 20,
                                          image: AssetImage(tongxun == 1
                                              ? "images/duankailianjie.png"
                                              : "images/yilianjie.png"),
                                        ),
                                      ],
                                    ),
                                  ),
                                  Container(
                                    width: 80,
                                    child: Column(
                                      mainAxisAlignment:
                                          MainAxisAlignment.center,
                                      children: [
                                        Text(
                                          "报警",
                                          style: TextStyle(
                                              color: const Color(0xFF2B85E4),
                                              fontSize: 16),
                                        ),
                                        Image(
                                          height: 40,
                                          width: 20,
                                          image: AssetImage(baojing == 1
                                              ? "images/duankailianjie.png"
                                              : "images/yilianjie.png"),
                                        ),
                                      ],
                                    ),
                                  ),
                                ],
                              ),
                            ),
                            Container(
                              height: MyApplication
                                          .loginuserinfo.userInfo.amHotuser ==
                                      1
                                  ? 220
                                  : 300,
                              margin: EdgeInsets.all(5),
                              decoration: BoxDecoration(
//                  border: new Border.all(color: Color(0xFF9E9E9E), width: 0.5), // 边色与边宽度
                                color: Colors.white,
                                // 底色
                                //        borderRadius: new BorderRadius.circular((20.0)), // 圆角度
                                borderRadius:
                                    BorderRadius.all(Radius.circular(5)),
                              ),
                              child: Column(
                                children: [
                                  Row(
                                    mainAxisAlignment: MainAxisAlignment.center,
                                    children: [
                                      Container(
                                        margin: EdgeInsets.only(
                                            left: 0,
                                            right: 0,
                                            top: 10,
                                            bottom: 0),
                                        decoration: BoxDecoration(
//                  border: new Border.all(color: Color(0xFF9E9E9E), width: 0.5), // 边色与边宽度
                                          color: Color(0xFF76B7FF),
                                          // 底色
                                          //        borderRadius: new BorderRadius.circular((20.0)), // 圆角度
                                          borderRadius: BorderRadius.all(
                                              Radius.circular(10)),
                                        ),
                                        width: 100,
                                        height: 120,
                                        child: Column(
                                          mainAxisAlignment:
                                              MainAxisAlignment.center,
//                      textDirection: TextDirection.,
                                          children: [
                                            Image(
                                              height: 35,
                                              width: 35,
                                              image: AssetImage(
                                                  "images/wendushezhi.png"),
                                            ),
                                            Text(
                                              "瞬时流量",
                                              style: TextStyle(
                                                  color: Colors.white,
                                                  fontSize: 16),
                                            ),
                                            Text(
                                              shunshiliuliang.toString(),
                                              style: TextStyle(
                                                  color: Colors.white,
                                                  fontSize: 20),
                                            ),
                                          ],
                                        ),
                                      ),
                                      Container(
                                        margin: EdgeInsets.only(
                                            left: 10,
                                            right: 0,
                                            top: 10,
                                            bottom: 0),
                                        decoration: BoxDecoration(
//                  border: new Border.all(color: Color(0xFF9E9E9E), width: 0.5), // 边色与边宽度
                                          color: Color(0xFF33DC93),
                                          // 底色
                                          //        borderRadius: new BorderRadius.circular((20.0)), // 圆角度
                                          borderRadius: BorderRadius.all(
                                              Radius.circular(10)),
                                        ),
                                        width: 100,
                                        height: 120,
                                        child: Column(
                                          mainAxisAlignment:
                                              MainAxisAlignment.center,
//                      textDirection: TextDirection.,
                                          children: [
                                            Image(
                                              height: 35,
                                              width: 35,
                                              image:
                                                  AssetImage("images/yali.png"),
                                            ),
                                            Text(
                                              "工作压力",
                                              style: TextStyle(
                                                  color: Colors.white,
                                                  fontSize: 16),
                                            ),
                                            Text(
                                              gongzuoyali.toString(),
                                              style: TextStyle(
                                                  color: Colors.white,
                                                  fontSize: 20),
                                            ),
                                          ],
                                        ),
                                      ),
                                      Container(
                                        margin: EdgeInsets.only(
                                            left: 10,
                                            right: 0,
                                            top: 10,
                                            bottom: 0),
                                        decoration: BoxDecoration(
//                  border: new Border.all(color: Color(0xFF9E9E9E), width: 0.5), // 边色与边宽度
                                          color: Color(0xFF6767FF),
                                          // 底色
                                          //        borderRadius: new BorderRadius.circular((20.0)), // 圆角度
                                          borderRadius: BorderRadius.all(
                                              Radius.circular(10)),
                                        ),
                                        width: 100,
                                        height: 120,
                                        child: Column(
                                          mainAxisAlignment:
                                              MainAxisAlignment.center,
//                      textDirection: TextDirection.,
                                          children: [
                                            Image(
                                              height: 35,
                                              width: 35,
                                              image: AssetImage(
                                                  "images/wendu.png"),
                                            ),
                                            Text(
                                              "工作温度",
                                              style: TextStyle(
                                                  color: Colors.white,
                                                  fontSize: 16),
                                            ),
                                            Text(
                                              gongzuowendu.toString(),
                                              style: TextStyle(
                                                  color: Colors.white,
                                                  fontSize: 20),
                                            ),
                                          ],
                                        ),
                                      ),
                                    ],
                                  ),
                                  MyApplication.loginuserinfo.userInfo
                                              .amHotuser ==
                                          1
                                      ?
                                  Container(
                                          height: 0,
//                                           margin: EdgeInsets.only(
//                                               left: 0,
//                                               right: 0,
//                                               top: 10,
//                                               bottom: 0),
//                                           padding: EdgeInsets.only(
//                                               left: 10,
//                                               right: 0,
//                                               top: 0,
//                                               bottom: 0),
//                                           decoration: BoxDecoration(
// //                  border: new Border.all(color: Color(0xFF9E9E9E), width: 0.5), // 边色与边宽度
//                                             color: Colors.white,
//                                             // 底色
//                                             image: DecorationImage(
//                                               image: AssetImage(
//                                                   "images/bolang.png"),
//                                               fit: BoxFit.fill,
//                                             ),
//                                             //        borderRadius: new BorderRadius.circular((20.0)), // 圆角度
//                                             borderRadius: BorderRadius.all(
//                                                 Radius.circular(5)),
//                                           ),
//                                           child: Row(
//                                             mainAxisAlignment:
//                                                 MainAxisAlignment.center,
//                                             children: [
//                                               Container(
//                                                 width: 110,
//                                                 padding: EdgeInsets.only(
//                                                     left: 0,
//                                                     right: 0,
//                                                     top: 20,
//                                                     bottom: 0),
//                                                 child: Column(
//                                                   mainAxisAlignment:
//                                                       MainAxisAlignment.center,
// //                      textDirection: TextDirection.,
//                                                   children: [
//                                                     Text(
//                                                       "本日累计汽量",
//                                                       style: TextStyle(
//                                                           color: Colors.white,
//                                                           fontSize: 12),
//                                                     ),
//                                                     Text(
//                                                       "0",
//                                                       style: TextStyle(
//                                                           color: Colors.white,
//                                                           fontSize: 14),
//                                                     ),
//                                                   ],
//                                                 ),
//                                               ),
//                                               Container(
//                                                 width: 0.5,
//                                                 margin: EdgeInsets.only(
//                                                     left: 0,
//                                                     right: 0,
//                                                     top: 20,
//                                                     bottom: 0),
//                                                 height: 30,
//                                                 decoration: BoxDecoration(
// //                  border: new Border.all(color: Color(0xFF9E9E9E), width: 0.5), // 边色与边宽度
//                                                   color: Colors.white,
//                                                   // 底色
//                                                   //        borderRadius: new BorderRadius.circular((20.0)), // 圆角度
//                                                   borderRadius:
//                                                       BorderRadius.all(
//                                                           Radius.circular(5)),
//                                                 ),
//                                               ),
//                                               Container(
//                                                 width: 110,
//                                                 padding: EdgeInsets.only(
//                                                     left: 0,
//                                                     right: 0,
//                                                     top: 20,
//                                                     bottom: 0),
//                                                 child: Column(
//                                                   mainAxisAlignment:
//                                                       MainAxisAlignment.center,
//                                                   children: [
//                                                     Text(
//                                                       "本月累计汽量",
//                                                       style: TextStyle(
//                                                           color: Colors.white,
//                                                           fontSize: 12),
//                                                     ),
//                                                     Text(
//                                                       "0",
//                                                       style: TextStyle(
//                                                           color: Colors.white,
//                                                           fontSize: 14),
//                                                     ),
//                                                   ],
//                                                 ),
//                                               ),
//                                               Container(
//                                                 width: 0.5,
//                                                 margin: EdgeInsets.only(
//                                                     left: 0,
//                                                     right: 0,
//                                                     top: 20,
//                                                     bottom: 0),
//                                                 height: 30,
//                                                 decoration: BoxDecoration(
// //                  border: new Border.all(color: Color(0xFF9E9E9E), width: 0.5), // 边色与边宽度
//                                                   color: Colors.white,
//                                                   // 底色
//                                                   //        borderRadius: new BorderRadius.circular((20.0)), // 圆角度
//                                                   borderRadius:
//                                                       BorderRadius.all(
//                                                           Radius.circular(5)),
//                                                 ),
//                                               ),
//                                               Container(
//                                                 width: 110,
//                                                 padding: EdgeInsets.only(
//                                                     left: 0,
//                                                     right: 0,
//                                                     top: 20,
//                                                     bottom: 0),
//                                                 child: Column(
//                                                   mainAxisAlignment:
//                                                       MainAxisAlignment.center,
//                                                   children: [
//                                                     Text(
//                                                       "剩余汽量",
//                                                       style: TextStyle(
//                                                           color: Colors.white,
//                                                           fontSize: 12),
//                                                     ),
//                                                     Text(
//                                                       "0",
//                                                       style: TextStyle(
//                                                           color: Colors.white,
//                                                           fontSize: 14),
//                                                     ),
//                                                   ],
//                                                 ),
//                                               ),
//                                             ],
//                                           ),
                                        )
                                      : Container(
                                          height: 150,
                                          margin: EdgeInsets.only(
                                              left: 0,
                                              right: 0,
                                              top: 10,
                                              bottom: 0),
                                          padding: EdgeInsets.only(
                                              left: 0,
                                              right: 0,
                                              top: 40,
                                              bottom: 0),
                                          decoration: BoxDecoration(
//                  border: new Border.all(color: Color(0xFF9E9E9E), width: 0.5), // 边色与边宽度
                                            color: Colors.white,
                                            // 底色
                                            image: DecorationImage(
                                              image: AssetImage(
                                                  "images/bolang.png"),
                                              fit: BoxFit.fill,
                                            ),
                                            //        borderRadius: new BorderRadius.circular((20.0)), // 圆角度
                                            borderRadius: BorderRadius.all(
                                                Radius.circular(5)),
                                          ),
                                          child: Column(
                                            children: [
                                              Row(
                                                mainAxisAlignment:
                                                    MainAxisAlignment.center,
                                                children: [
                                                  Container(
                                                    width: 82,
                                                    padding: EdgeInsets.only(
                                                        left: 0,
                                                        right: 0,
                                                        top: 20,
                                                        bottom: 0),
                                                    child: Column(
                                                      mainAxisAlignment:
                                                          MainAxisAlignment
                                                              .center,
//                      textDirection: TextDirection.,
                                                      children: [
                                                        Text(
                                                          "瞬时总售热",
                                                          style: TextStyle(
                                                              color:
                                                                  Colors.white,
                                                              fontSize: 12),
                                                        ),
                                                        Text(
                                                          getDayMonthTotalFlowVoBean != null &&
                                                                  getDayMonthTotalFlowVoBean
                                                                          .result !=
                                                                      null &&
                                                                  getDayMonthTotalFlowVoBean
                                                                          .result
                                                                          .totalHeatSale !=
                                                                      null
                                                              ? getDayMonthTotalFlowVoBean
                                                                      .result
                                                                      .totalHeatSale
                                                                      .toString() +
                                                                  "t"
                                                              : "0t",
                                                          style: TextStyle(
                                                              color:
                                                                  Colors.white,
                                                              fontSize: 14),
                                                        ),
                                                      ],
                                                    ),
                                                  ),
                                                  Container(
                                                    width: 0.5,
                                                    margin: EdgeInsets.only(
                                                        left: 0,
                                                        right: 0,
                                                        top: 20,
                                                        bottom: 0),
                                                    height: 30,
                                                    decoration: BoxDecoration(
//                  border: new Border.all(color: Color(0xFF9E9E9E), width: 0.5), // 边色与边宽度
                                                      color: Colors.white,
                                                      // 底色
                                                      //        borderRadius: new BorderRadius.circular((20.0)), // 圆角度
                                                      borderRadius:
                                                          BorderRadius.all(
                                                              Radius.circular(
                                                                  5)),
                                                    ),
                                                  ),
                                                  Container(
                                                    width: 82,
                                                    padding: EdgeInsets.only(
                                                        left: 0,
                                                        right: 0,
                                                        top: 20,
                                                        bottom: 0),
                                                    child: Column(
                                                      mainAxisAlignment:
                                                          MainAxisAlignment
                                                              .center,
//                      textDirection: TextDirection.,
                                                      children: [
                                                        Text(
                                                          "瞬时总供热",
                                                          style: TextStyle(
                                                              color:
                                                                  Colors.white,
                                                              fontSize: 12),
                                                        ),
                                                        Text(
                                                          getDayMonthTotalFlowVoBean != null &&
                                                                  getDayMonthTotalFlowVoBean
                                                                          .result !=
                                                                      null &&
                                                                  getDayMonthTotalFlowVoBean
                                                                          .result
                                                                          .totalHeating !=
                                                                      null
                                                              ? getDayMonthTotalFlowVoBean
                                                                      .result
                                                                      .totalHeating
                                                                      .toString() +
                                                                  "t"
                                                              : "0t",
                                                          style: TextStyle(
                                                              color:
                                                                  Colors.white,
                                                              fontSize: 14),
                                                        ),
                                                      ],
                                                    ),
                                                  ),
                                                  Container(
                                                    width: 0.5,
                                                    margin: EdgeInsets.only(
                                                        left: 0,
                                                        right: 0,
                                                        top: 20,
                                                        bottom: 0),
                                                    height: 30,
                                                    decoration: BoxDecoration(
//                  border: new Border.all(color: Color(0xFF9E9E9E), width: 0.5), // 边色与边宽度
                                                      color: Colors.white,
                                                      // 底色
                                                      //        borderRadius: new BorderRadius.circular((20.0)), // 圆角度
                                                      borderRadius:
                                                          BorderRadius.all(
                                                              Radius.circular(
                                                                  5)),
                                                    ),
                                                  ),
                                                  Container(
                                                    width: 82,
                                                    padding: EdgeInsets.only(
                                                        left: 0,
                                                        right: 0,
                                                        top: 20,
                                                        bottom: 0),
                                                    child: Column(
                                                      mainAxisAlignment:
                                                          MainAxisAlignment
                                                              .center,
                                                      children: [
                                                        Text(
                                                          "今日瞬时最高",
                                                          style: TextStyle(
                                                              color:
                                                                  Colors.white,
                                                              fontSize: 12),
                                                        ),
                                                        Text(
                                                          getDayMonthTotalFlowVoBean != null &&
                                                                  getDayMonthTotalFlowVoBean
                                                                          .result !=
                                                                      null &&
                                                                  getDayMonthTotalFlowVoBean
                                                                          .result
                                                                          .maxInstantFlow !=
                                                                      null
                                                              ? getDayMonthTotalFlowVoBean
                                                                      .result
                                                                      .maxInstantFlow
                                                                      .toString() +
                                                                  "t"
                                                              : "0t",
                                                          style: TextStyle(
                                                              color:
                                                                  Colors.white,
                                                              fontSize: 14),
                                                        ),
                                                      ],
                                                    ),
                                                  ),
                                                  Container(
                                                    width: 0.5,
                                                    margin: EdgeInsets.only(
                                                        left: 0,
                                                        right: 0,
                                                        top: 20,
                                                        bottom: 0),
                                                    height: 30,
                                                    decoration: BoxDecoration(
//                  border: new Border.all(color: Color(0xFF9E9E9E), width: 0.5), // 边色与边宽度
                                                      color: Colors.white,
                                                      // 底色
                                                      //        borderRadius: new BorderRadius.circular((20.0)), // 圆角度
                                                      borderRadius:
                                                          BorderRadius.all(
                                                              Radius.circular(
                                                                  5)),
                                                    ),
                                                  ),
                                                  Container(
                                                    width: 82,
                                                    padding: EdgeInsets.only(
                                                        left: 0,
                                                        right: 0,
                                                        top: 20,
                                                        bottom: 0),
                                                    child: Column(
                                                      mainAxisAlignment:
                                                          MainAxisAlignment
                                                              .center,
                                                      children: [
                                                        Text(
                                                          "今日瞬时最低",
                                                          style: TextStyle(
                                                              color:
                                                                  Colors.white,
                                                              fontSize: 12),
                                                        ),
                                                        Text(
                                                          getDayMonthTotalFlowVoBean != null &&
                                                                  getDayMonthTotalFlowVoBean
                                                                          .result !=
                                                                      null &&
                                                                  getDayMonthTotalFlowVoBean
                                                                          .result
                                                                          .minInstantFlow !=
                                                                      null
                                                              ? getDayMonthTotalFlowVoBean
                                                                      .result
                                                                      .minInstantFlow
                                                                      .toString() +
                                                                  "t"
                                                              : "0t",
                                                          style: TextStyle(
                                                              color:
                                                                  Colors.white,
                                                              fontSize: 14),
                                                        ),
                                                      ],
                                                    ),
                                                  ),
                                                ],
                                              ),
                                              Container(
                                                width: rpxw * 700,
                                                margin: EdgeInsets.only(
                                                    left: 0,
                                                    right: 0,
                                                    top: 10,
                                                    bottom: 0),
                                                height: 0.5,
                                                decoration: BoxDecoration(
                                                  color: Colors.white,
                                                  borderRadius:
                                                      BorderRadius.all(
                                                          Radius.circular(5)),
                                                ),
                                              ),
                                              Expanded(
                                                child: Row(
                                                  mainAxisAlignment:
                                                      MainAxisAlignment.start,
                                                  children: [
                                                    _columnText(
                                                        "昨日汽量",
                                                        (getDayMonthTotalFlowVoBean != null &&
                                                                getDayMonthTotalFlowVoBean
                                                                        .result !=
                                                                    null &&
                                                                getDayMonthTotalFlowVoBean
                                                                        .result
                                                                        .yesterDayFlow !=
                                                                    null
                                                            ? getDayMonthTotalFlowVoBean
                                                                    .result
                                                                    .yesterDayFlow
                                                                    .toString() +
                                                                "t"
                                                            : "0t")),
                                                    Container(
                                                        width: 0.5,
                                                        height: 30,
                                                        decoration: BoxDecoration(
                                                            color: Colors.white,
                                                            borderRadius:
                                                                BorderRadius
                                                                    .all(Radius
                                                                        .circular(
                                                                            5)))),
                                                    _columnText(
                                                        "今日汽量",
                                                        (getDayMonthTotalFlowVoBean != null &&
                                                                getDayMonthTotalFlowVoBean
                                                                        .result !=
                                                                    null &&
                                                                getDayMonthTotalFlowVoBean
                                                                        .result
                                                                        .dayTotalFlow !=
                                                                    null
                                                            ? getDayMonthTotalFlowVoBean
                                                                    .result
                                                                    .dayTotalFlow
                                                                    .toString() +
                                                                "t"
                                                            : "0t")),
                                                    Container(
                                                        width: 0.5,
                                                        height: 30,
                                                        decoration: BoxDecoration(
                                                            color: Colors.white,
                                                            borderRadius:
                                                                BorderRadius
                                                                    .all(Radius
                                                                        .circular(
                                                                            5)))),
                                                    _columnText(
                                                        "本月汽量",
                                                        (getDayMonthTotalFlowVoBean != null &&
                                                                getDayMonthTotalFlowVoBean
                                                                        .result !=
                                                                    null &&
                                                                getDayMonthTotalFlowVoBean
                                                                        .result
                                                                        .monthTotalFlow !=
                                                                    null
                                                            ? getDayMonthTotalFlowVoBean
                                                                    .result
                                                                    .monthTotalFlow
                                                                    .toString() +
                                                                "t"
                                                            : "0t")),
                                                    Container(
                                                        width: 0.5,
                                                        height: 30,
                                                        decoration: BoxDecoration(
                                                            color: Colors.white,
                                                            borderRadius:
                                                                BorderRadius
                                                                    .all(Radius
                                                                        .circular(
                                                                            5)))),
                                                    _columnText(
                                                        "本年度汽量",
                                                        (getDayMonthTotalFlowVoBean != null &&
                                                                getDayMonthTotalFlowVoBean
                                                                        .result !=
                                                                    null &&
                                                                getDayMonthTotalFlowVoBean
                                                                        .result
                                                                        .yearDayFlow !=
                                                                    null
                                                            ? getDayMonthTotalFlowVoBean
                                                                    .result
                                                                    .yearDayFlow
                                                                    .toString() +
                                                                "t"
                                                            : "0t")),
                                                    Container(
                                                        width: 0.5,
                                                        height: 30,
                                                        decoration: BoxDecoration(
                                                            color: Colors.white,
                                                            borderRadius:
                                                                BorderRadius
                                                                    .all(Radius
                                                                        .circular(
                                                                            5)))),
                                                  ],
                                                ),
                                              ),
                                            ],
                                          )),
                                ],
                              ),
                            ),

//                       Container(
//                         height: 80,
//                         margin: EdgeInsets.all(5),
//                         padding:  EdgeInsets.only(left: 10, right: 0, top:0, bottom: 0),
//                         decoration: BoxDecoration(
// //                  border: new Border.all(color: Color(0xFF9E9E9E), width: 0.5), // 边色与边宽度
//                           color: Colors.white, // 底色
//                           //        borderRadius: new BorderRadius.circular((20.0)), // 圆角度
//                           borderRadius: BorderRadius.all(Radius.circular(5)),
//                         ),
//                         child:
//                         Row(
//                           mainAxisAlignment: MainAxisAlignment.center,
//                           children: [
//                             InkWell(
//                               onTap: (){
//
//                                 if(MyApplication.loginuserinfo.userInfo.amHotuser==0){
//                                   Navigator.push(context, MaterialPageRoute(builder: (context) {
//                                     return new Xunjian2Page();
//                                   }));
//                                 }else{
//                                   Fluttertoast.showToast(msg: "无此权限");
//                                 }
//
//                               } ,
//                               child:
//                               Container(
//                                 width: 110,
//                                 child:
//                                 Column(
//                                   mainAxisAlignment: MainAxisAlignment.center,
//                                   children: [
//                                     Image(
//                                       height: 50,
//                                       width: 50,
//                                       image:AssetImage("images/xunjiandian.png"),),
//                                     Text("智能巡检",style: TextStyle(color: Colors.black,fontSize: 14),),
//                                   ],
//
//                                 ),
//                               ),
//                             ),
//                             InkWell(
//                               onTap: (){
//                                 if(MyApplication.loginuserinfo.userInfo.amHotuser==0){
//                                   Navigator.push(context, MaterialPageRoute(builder: (context) {
//                                     return new ZhifaScreen();
//                                   }));
//                                 }else{
//                                   Fluttertoast.showToast(msg: "无此权限");
//                                 }
//                               } ,
//                               child:
//                               Container(
//                                 width: 110,
//                                 child:
//                                 Column(
//                                   mainAxisAlignment: MainAxisAlignment.center,
// //                      textDirection: TextDirection.,
//                                   children: [
//                                     Image(
//                                       height: 50,
//                                       width: 50,
//                                       image:AssetImage("images/xianchangzhifa.png"),),
//                                     Text("现场执法",style: TextStyle(color: Colors.black,fontSize: 14),),
//
//                                   ],
//                                 ),
//                               ),
//                             ),
//
//                             InkWell(
//                               onTap: (){
//                                 Fluttertoast.showToast(msg: "故障报告");
//                                 Navigator.push(context, MaterialPageRoute(builder: (context) {
//                                   return new GuzhangBaogaoScreen();
//                                 }));
//                               } ,
//                               child:
//                               Container(
//                                 width: 110,
//                                 child:
//                                 Column(
//                                   mainAxisAlignment: MainAxisAlignment.center,
//                                   children: [
//                                     Image(
//                                       height: 50,
//                                       width: 50,
//                                       image:AssetImage("images/guzhangweihu.png"),),
//                                     Text("故障报告",style: TextStyle(color: Colors.black,fontSize: 14),),
//                                   ],
//                                 ),
//                               ),
//                             ),
//                           ],
//                         ),
//                       ),
//                       MyApplication.loginuserinfo.userInfo.amHotuser!=1?
//                       Container(
//                         height: 60,
//                         margin: EdgeInsets.all(5),
//                         padding:  EdgeInsets.only(left: 10, right: 0, top:0, bottom: 0),
//                         decoration: BoxDecoration(
// //                  border: new Border.all(color: Color(0xFF9E9E9E), width: 0.5), // 边色与边宽度
//                           color: Colors.white, // 底色
//                           //        borderRadius: new BorderRadius.circular((20.0)), // 圆角度
//                           borderRadius: BorderRadius.all(Radius.circular(5)),
//                         ),
//                         child:
//                         Row(
//                           mainAxisAlignment: MainAxisAlignment.center,
//                           children: [
//                             Container(
//                               width: 100,
//                               child:
//                               Column(
//                                 mainAxisAlignment: MainAxisAlignment.center,
// //                      textDirection: TextDirection.,
//                                 children: [
//                                   Text("巡检任务总数",style: TextStyle(color: const Color(0xFF2B85E4),fontSize: 14),),
//                                   Text( "$totaltask",style: TextStyle(color: const Color(0xFF2B85E4),fontSize: 14),),
//
//                                 ],
//                               ),
//                             ),
//                             Container(
//                               width: 100,
//                               child:
//                               Column(
//                                 mainAxisAlignment: MainAxisAlignment.center,
//                                 children: [ Text("已完成",style: TextStyle(color: const Color(0xFF2B85E4),fontSize: 14),),
//                                   Text( "$successtask",style: TextStyle(color: const Color(0xFF2B85E4),fontSize: 14),),
//                                 ],
//                               ),
//                             ),
//                             Container(
//                               width: 100,
//                               child:
//                               Column(
//                                 mainAxisAlignment: MainAxisAlignment.center,
//                                 children: [ Text("未完成",style: TextStyle(color: const Color(0xFF2B85E4),fontSize: 14),),
//                                   Text( "$fitertask",style: TextStyle(color: const Color(0xFF2B85E4),fontSize: 14),),
//                                 ],
//                               ),
//                             ),
//                           ],
//                         ),
//                       ):Container(),
                            Container(
                              height: 310,
                              margin: EdgeInsets.all(5),
                              padding: EdgeInsets.only(
                                  left: 10, right: 0, top: 0, bottom: 0),
                              decoration: BoxDecoration(
//                  border: new Border.all(color: Color(0xFF9E9E9E), width: 0.5), // 边色与边宽度
                                color: Colors.white,
                                // 底色
                                //        borderRadius: new BorderRadius.circular((20.0)), // 圆角度
                                borderRadius:
                                    BorderRadius.all(Radius.circular(5)),
                              ),
                              child: Column(
                                children: [
                                  // Container(
                                  //   child:
                                  //   Row(
                                  //     children: [
                                  //       Image(
                                  //         height: 40,
                                  //         width: 20,
                                  //         image:AssetImage("images/yinliang.png"),),
                                  //       Text("请于2020年4月25日前完成缴费",style: TextStyle(color: const Color(0xFF494949),fontSize: 14),),
                                  //
                                  //     ],
                                  //
                                  //   ),
                                  //
                                  // ),
                                  Container(
                                    margin: EdgeInsets.only(
                                        left: 0, right: 0, top: 10, bottom: 0),
                                    child: Row(
                                      children: [
                                        Container(
                                          width: 3,
                                          margin: EdgeInsets.only(
                                              left: 0,
                                              right: 10,
                                              top: 2,
                                              bottom: 0),
                                          height: 15,
                                          decoration: BoxDecoration(
//                  border: new Border.all(color: Color(0xFF9E9E9E), width: 0.5), // 边色与边宽度
                                            color: Colors.blue, // 底色
                                            //        borderRadius: new BorderRadius.circular((20.0)), // 圆角度
                                          ),
                                        ),
                                        Text(
                                          "用户概况",
                                          style: TextStyle(
                                              color: Colors.black,
                                              fontSize: 14),
                                        ),
                                        Flexible(
                                            fit: FlexFit.tight,
                                            child: SizedBox()),
                                        Container(
                                          margin: EdgeInsets.only(
                                              left: 170,
                                              right: 5,
                                              top: 0,
                                              bottom: 0),
                                          child: Text(
                                            "总数：",
                                            style: TextStyle(
                                                color: Colors.black,
                                                fontSize: 14),
                                          ),
                                        ),
                                        Text(
                                          "$hotusercount",
                                          style: TextStyle(
                                              color: Color(0xFF338AE5),
                                              fontSize: 14),
                                        ),
                                        Container(
                                          width: 10,
                                        ),
                                      ],
                                    ),
                                  ),
                                  Container(
                                    child: Row(
                                      mainAxisAlignment:
                                          MainAxisAlignment.center,
                                      children: [
                                        Container(
                                          height: 80,
                                          margin: EdgeInsets.all(5),
                                          padding: EdgeInsets.only(
                                              left: 0,
                                              right: 0,
                                              top: 0,
                                              bottom: 0),
                                          decoration: BoxDecoration(
//                  border: new Border.all(color: Color(0xFF9E9E9E), width: 0.5), // 边色与边宽度
                                            color: Colors.white,
                                            // 底色
                                            //        borderRadius: new BorderRadius.circular((20.0)), // 圆角度
                                            borderRadius: BorderRadius.all(
                                                Radius.circular(5)),
                                          ),
                                          child: Row(
                                            mainAxisAlignment:
                                                MainAxisAlignment.center,
                                            children: [
                                              InkWell(
                                                onTap: () {
                                                  Navigator.push(context,
                                                      MaterialPageRoute(
                                                          builder: (context) {
                                                    return new ReYongHuXinXiScreen();
                                                  }));
                                                },
                                                child: Container(
                                                  width: 80,
                                                  child: Column(
                                                    mainAxisAlignment:
                                                        MainAxisAlignment
                                                            .center,
//                      textDirection: TextDirection.,
                                                    children: [
                                                      Image(
                                                        height: 50,
                                                        width: 50,
                                                        image: AssetImage(
                                                            "images/reyonghuixnxi.png"),
                                                      ),
                                                      Text(
                                                        "热用户信息",
                                                        style: TextStyle(
                                                            color: Color(
                                                                0xFF8B8B8B),
                                                            fontSize: 12),
                                                      ),
                                                    ],
                                                  ),
                                                ),
                                              ),
                                              InkWell(
                                                onTap: () {
                                                  Navigator.push(context,
                                                      MaterialPageRoute(
                                                          builder: (context) {
                                                    return new ReYongHuShuJuNewScreen();
                                                  }));
                                                },
                                                child: Container(
                                                  width: 80,
                                                  child: Column(
                                                    mainAxisAlignment:
                                                        MainAxisAlignment
                                                            .center,
                                                    children: [
                                                      Image(
                                                        height: 50,
                                                        width: 50,
                                                        image: AssetImage(
                                                            "images/reyonghushuju.png"),
                                                      ),
                                                      Text(
                                                        "热用户数据",
                                                        style: TextStyle(
                                                            color: Color(
                                                                0xFF8B8B8B),
                                                            fontSize: 12),
                                                      ),
                                                    ],
                                                  ),
                                                ),
                                              ),
                                              InkWell(
                                                onTap: () {
                                                  Navigator.push(context,
                                                      MaterialPageRoute(
                                                          builder: (context) {
                                                    return MyApplication
                                                                .loginuserinfo
                                                                .userInfo
                                                                .amHotuser !=
                                                            1
                                                        ? (new messagecenterPage())
                                                        : (new hotusermessagecenterPage());
                                                  }));
                                                },
                                                child: Container(
                                                  width: 80,
                                                  child: Column(
                                                    mainAxisAlignment:
                                                        MainAxisAlignment
                                                            .center,
                                                    children: [
                                                      Image(
                                                        height: 50,
                                                        width: 50,
                                                        image: AssetImage(
                                                            "images/xiaoxi.png"),
                                                      ),
                                                      Text(
                                                        "消息中心",
                                                        style: TextStyle(
                                                            color: Color(
                                                                0xFF8B8B8B),
                                                            fontSize: 12),
                                                      ),
                                                    ],
                                                  ),
                                                ),
                                              ),
                                              InkWell(
                                                onTap: () {
                                                  Navigator.push(context,
                                                      MaterialPageRoute(
                                                          builder: (context) {
                                                    return new yongliangshenbaoscreen();
                                                  }));
                                                },
                                                child: Container(
                                                  width: 80,
                                                  child: Column(
                                                    mainAxisAlignment:
                                                        MainAxisAlignment
                                                            .center,
                                                    children: [
                                                      Image(
                                                        height: 50,
                                                        width: 50,
                                                        image: AssetImage(
                                                            "images/meiriyongliangtongbao.png"),
                                                      ),
                                                      Text(
                                                        "日用量申报",
                                                        style: TextStyle(
                                                            color: Color(
                                                                0xFF8B8B8B),
                                                            fontSize: 12),
                                                      ),
                                                    ],
                                                  ),
                                                ),
                                              ),
                                            ],
                                          ),
                                        ),
                                      ],
                                    ),
                                  ),
                                  Container(
                                    child: Row(
                                      mainAxisAlignment:
                                          MainAxisAlignment.center,
                                      children: [
                                        Container(
                                          height: 80,
                                          margin: EdgeInsets.all(5),
                                          padding: EdgeInsets.only(
                                              left: 0,
                                              right: 0,
                                              top: 0,
                                              bottom: 0),
                                          decoration: BoxDecoration(
//                  border: new Border.all(color: Color(0xFF9E9E9E), width: 0.5), // 边色与边宽度
                                            color: Colors.white,
                                            // 底色
                                            //        borderRadius: new BorderRadius.circular((20.0)), // 圆角度
                                            borderRadius: BorderRadius.all(
                                                Radius.circular(5)),
                                          ),
                                          child: Row(
                                            children: [
                                              InkWell(
                                                onTap: () {
                                                  if (MyApplication
                                                          .loginuserinfo
                                                          .userInfo
                                                          .amHotuser !=
                                                      1) {
                                                    Navigator.push(context,
                                                        MaterialPageRoute(
                                                            builder: (context) {
                                                      return new LineChartSample2test();
                                                    }));
                                                  } else {
                                                    LocalToast.toast(context,
                                                        msg: "无权限访问！");
                                                  }
                                                },
                                                child: Container(
                                                  width: 80,
                                                  child: Column(
                                                    mainAxisAlignment:
                                                        MainAxisAlignment
                                                            .center,
//                      textDirection: TextDirection.,
                                                    children: [
                                                      Image(
                                                        height: 50,
                                                        width: 50,
                                                        image: AssetImage(
                                                            "images/lishiquxian.png"),
                                                      ),
                                                      Text(
                                                        "历史数据",
                                                        style: TextStyle(
                                                            color: Color(
                                                                0xFF8B8B8B),
                                                            fontSize: 12),
                                                      ),
                                                    ],
                                                  ),
                                                ),
                                              ),
                                              InkWell(
                                                onTap: () {
                                                  Navigator.push(context,
                                                      MaterialPageRoute(
                                                          builder: (context) {
                                                    return new fuheyucescreen();
                                                  }));
                                                },
                                                child: Container(
                                                  width: 80,
                                                  child: Column(
                                                    mainAxisAlignment:
                                                        MainAxisAlignment
                                                            .center,
                                                    children: [
                                                      Image(
                                                        height: 50,
                                                        width: 50,
                                                        image: AssetImage(
                                                            "images/fuheyuce.png"),
                                                      ),
                                                      Text(
                                                        "负荷预测",
                                                        style: TextStyle(
                                                            color: Color(
                                                                0xFF8B8B8B),
                                                            fontSize: 12),
                                                      ),
                                                    ],
                                                  ),
                                                ),
                                              ),
                                              InkWell(
                                                onTap: () {
                                                  Navigator.push(context,
                                                      MaterialPageRoute(
                                                          builder: (context) {
                                                    return new tongjibaobiaoPage();
                                                  }));
                                                },
                                                child: Container(
                                                  width: 80,
                                                  child: Column(
                                                    mainAxisAlignment:
                                                        MainAxisAlignment
                                                            .center,
                                                    children: [
                                                      Image(
                                                        height: 50,
                                                        width: 50,
                                                        image: AssetImage(
                                                            "images/lishishuju.png"),
                                                      ),
                                                      Text(
                                                        "统计报表",
                                                        style: TextStyle(
                                                            color: Color(
                                                                0xFF8B8B8B),
                                                            fontSize: 12),
                                                      ),
                                                    ],
                                                  ),
                                                ),
                                              ),
                                              InkWell(
                                                onTap: () {
                                                  Navigator.push(context,
                                                      MaterialPageRoute(
                                                          builder: (context) {
                                                    return new jiesuanbaobiaoPage();
                                                  }));
                                                },
                                                child: Container(
                                                  width: 80,
                                                  child: Column(
                                                    mainAxisAlignment:
                                                        MainAxisAlignment
                                                            .center,
                                                    children: [
                                                      Image(
                                                        height: 50,
                                                        width: 50,
                                                        image: AssetImage(
                                                            "images/yonghubaogao.png"),
                                                      ),
                                                      Text(
                                                        "结算报表",
                                                        style: TextStyle(
                                                            color: Color(
                                                                0xFF8B8B8B),
                                                            fontSize: 12),
                                                      ),
                                                    ],
                                                  ),
                                                ),
                                              ),
                                            ],
                                          ),
                                        ),
                                      ],
                                    ),
                                  ),

                                  Container(
                                    child: Row(
                                      mainAxisAlignment:
                                          MainAxisAlignment.center,
                                      children: [
                                        Container(
                                          height: 80,
                                          margin: EdgeInsets.all(5),
                                          padding: EdgeInsets.only(
                                              left: 0,
                                              right: 0,
                                              top: 0,
                                              bottom: 0),
                                          decoration: BoxDecoration(
//                  border: new Border.all(color: Color(0xFF9E9E9E), width: 0.5), // 边色与边宽度
                                            color: Colors.white,
                                            // 底色
                                            //        borderRadius: new BorderRadius.circular((20.0)), // 圆角度
                                            borderRadius: BorderRadius.all(
                                                Radius.circular(5)),
                                          ),
                                          child: Row(
                                            children: [
                                              InkWell(
                                                onTap: () {
                                                  if (MyApplication
                                                          .loginuserinfo
                                                          .userInfo
                                                          .amHotuser !=
                                                      1) {
                                                    Navigator.push(context,
                                                        MaterialPageRoute(
                                                            builder: (context) {
                                                      return new TradeAmountActivity();
                                                    }));
                                                  } else {
                                                    LocalToast.toast(context,
                                                        msg: "无权限访问！");
                                                  }
                                                },
                                                child: Container(
                                                  width: 80,
                                                  child: Column(
                                                    mainAxisAlignment:
                                                        MainAxisAlignment
                                                            .center,
//                      textDirection: TextDirection.,
                                                    children: [
                                                      Image(
                                                        height: 50,
                                                        width: 50,
                                                        image: AssetImage(
                                                            "images/hangyeyongqi.png"),
                                                      ),
                                                      Text(
                                                        "行业用汽",
                                                        style: TextStyle(
                                                            color: Color(
                                                                0xFF8B8B8B),
                                                            fontSize: 12),
                                                      ),
                                                    ],
                                                  ),
                                                ),
                                              ),
                                              // InkWell(
                                              //   onTap: (){
                                              //     // if( MyApplication.loginuserinfo.userInfo.amHotuser!=1){
                                              //       Navigator.push(context, MaterialPageRoute(builder: (context) {
                                              //         return new timebaobiaoActivity();
                                              //       }));
                                              //     // }else{
                                              //     //   LocalToast.toast(context,msg: "无权限访问！");
                                              //     // }
                                              //   } ,
                                              //   child:
                                              //   Container(
                                              //     width: 80,
                                              //     child:
                                              //     Column(
                                              //       mainAxisAlignment: MainAxisAlignment.center,
                                              //       children: [
                                              //         Image(
                                              //           height: 50,
                                              //           width: 50,
                                              //           image:AssetImage("images/fenshibaobiao.png"),),
                                              //         Text("分时报表",style: TextStyle(color: Color(0xFF8B8B8B),fontSize: 12),),
                                              //       ],
                                              //
                                              //     ),
                                              //   ),),
                                              InkWell(
                                                onTap: () {
                                                  // Navigator.push(context, MaterialPageRoute(builder: (context) {
                                                  //   return new tongjibaobiaoPage();
                                                  // }));
                                                },
                                                child: Container(
                                                  width: 80,
                                                  child: Column(
                                                    mainAxisAlignment:
                                                        MainAxisAlignment
                                                            .center,
                                                    children: [
                                                      // Image(
                                                      //   height: 50,
                                                      //   width: 50,
                                                      //   image:AssetImage("images/lishishuju.png"),),
                                                      // Text("统计报表",style: TextStyle(color: Color(0xFF8B8B8B),fontSize: 12),),
                                                    ],
                                                  ),
                                                ),
                                              ),
                                              InkWell(
                                                onTap: () {
                                                  // Navigator.push(context, MaterialPageRoute(builder: (context) {
                                                  //   return new tongjibaobiaoPage();
                                                  // }));
                                                },
                                                child: Container(
                                                  width: 80,
                                                  child: Column(
                                                    mainAxisAlignment:
                                                    MainAxisAlignment
                                                        .center,
                                                    children: [
                                                      // Image(
                                                      //   height: 50,
                                                      //   width: 50,
                                                      //   image:AssetImage("images/lishishuju.png"),),
                                                      // Text("统计报表",style: TextStyle(color: Color(0xFF8B8B8B),fontSize: 12),),
                                                    ],
                                                  ),
                                                ),
                                              ),
                                              InkWell(
                                                onTap: () {
                                                  // Navigator.push(context, MaterialPageRoute(builder: (context) {
                                                  //   return new jiesuanbaobiaoPage();
                                                  // }));
                                                },
                                                child: Container(
                                                  width: 80,
                                                  child: Column(
                                                    mainAxisAlignment:
                                                        MainAxisAlignment
                                                            .center,
                                                    children: [
                                                      // Image(
                                                      //   height: 50,
                                                      //   width: 50,
                                                    ],
                                                  ),
                                                ),
                                              ),
                                            ],
                                          ),
                                        ),
                                      ],
                                    ),
                                  ),
                                ],
                              ),
                            ),

                            showChart() ? _chartWidget() : Container(),
                          ],
                        ),
                      ),
                    ),
                  ],
                )
              : Container()),
    );
  }

  bool showChart() {
    if (MyApplication.loginuserinfo.userInfo.amHotuser == 0) {
      if (chartdata == 1) {
        if (null != hotLineBean.result) {
          if (hotLineBean.result.length > 0) {
            return true;
          }
        }
      }
    }
    return false;
  }

  Widget _columnText(var name, var sum) {
    return Expanded(
      child: Container(
        padding: EdgeInsets.only(left: 0, right: 0, top: 0, bottom: 0),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Text("$name", style: TextStyle(color: Colors.white, fontSize: 12)),
            Text("$sum", style: TextStyle(color: Colors.white, fontSize: 14))
          ],
        ),
      ),
    );
  }

  // 折线图
  Widget _chartWidget() {
    List<charts.Series<SeriesDatas, int>> seriesList = [
      new charts.Series<SeriesDatas, int>(
        id: '瞬时供热合计',
        colorFn: (_, __) => charts.MaterialPalette.deepOrange.shadeDefault,
        domainFn: (SeriesDatas sales, _) => sales.X,
        measureFn: (SeriesDatas sales, _) => sales.Y,
        data: data1(),
      ),
      new charts.Series<SeriesDatas, int>(
        id: '瞬时售热合计',
        colorFn: (_, __) => charts.MaterialPalette.green.shadeDefault,
        domainFn: (SeriesDatas sales, _) => sales.X,
        measureFn: (SeriesDatas sales, _) => sales.Y,
        data: data2(),
      ),
    ];

    var chart = new charts.LineChart(
      seriesList,
      animate: false,
      defaultRenderer: charts.LineRendererConfig(
        // 折线图绘制的配置
        includeArea: false,
        includePoints: false,
        includeLine: true,
        stacked: false,
      ),
      domainAxis: charts.NumericAxisSpec(
        // 主轴的配置
        // tickFormatterSpec: DomainFormatterSpec(widget.dateRange), // tick 值的格式化，这里把 num 转换成 String
        renderSpec: charts.SmallTickRendererSpec(
          // 主轴绘制的配置
          tickLengthPx: 0,
          // 刻度标识突出的长度
          labelOffsetFromAxisPx: 12,
          // 刻度文字距离轴线的位移
          labelStyle: charts.TextStyleSpec(
            // 刻度文字的样式
            fontSize: 0,
          ),
          lineStyle: charts.LineStyleSpec(
            thickness: 1,
          ),
          axisLineStyle: charts.LineStyleSpec(
              // 轴线的样式
              ),
        ),
        tickProviderSpec: charts.BasicNumericTickProviderSpec(
          // 轴线刻度配置
          dataIsInWholeNumbers: false,
          desiredTickCount: 13, // 期望显示几个刻度
        ),
      ),
      primaryMeasureAxis: charts.NumericAxisSpec(
        // 交叉轴的配置，参数参考主轴配置
        showAxisLine: false, // 显示轴线
        // tickFormatterSpec: MeasureFormatterSpec(),
        tickProviderSpec: charts.BasicNumericTickProviderSpec(
          dataIsInWholeNumbers: false,
          desiredTickCount: 4,
        ),
        renderSpec: charts.GridlineRendererSpec(
          // 交叉轴刻度水平线
          tickLengthPx: 0,
          labelOffsetFromAxisPx: 12,
          labelStyle: charts.TextStyleSpec(
            // color: ChartUtil.getChartColor(HColors.lightGrey),
            fontSize: 10,
          ),
          lineStyle: charts.LineStyleSpec(
              // color: ChartUtil.getChartColor(ChartUtil.lightBlue),
              ),
          axisLineStyle: charts.LineStyleSpec(
              // color: ChartUtil.getChartColor(ChartUtil.lightBlue),
              ),
        ),
      ),
      behaviors: [
        new charts.SeriesLegend(
            // 图例位置 在左侧start 和右侧end
            position: charts.BehaviorPosition.top,
            // 图例条目  [horizo​​ntalFirst]设置为false，图例条目将首先作为新行而不是新列增长
            horizontalFirst: false,
            // 每个图例条目周围的填充Padding
            cellPadding: new EdgeInsets.only(right: 4.0, bottom: 4.0),
            // 显示度量
            showMeasures: true,
            // 度量格式
            measureFormatter: (num value) {
              return value == null ? '-' : '${value}t   ' + getTime(value);
            }
            // ,
            ),
      ],
    );

    return new Card(
      child: Container(
        height: 354,
        // padding: new EdgeInsets.fromLTRB(16, 10, 16, 20),
        margin: new EdgeInsets.only(top: 20),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            new Center(
              child: new Text(
                '售热总流量（单位：吨）',
                style: TextStyle(
                  color: Color.fromRGBO(0, 0, 0, 1.0), //opacity：不透明度
                  fontFamily: 'PingFangBold',
                  fontSize: 15.0,
                ),
              ),
            ),
            new Padding(
              padding: new EdgeInsets.all(10.0),
              child: new SizedBox(
                height: 300.0,
                child: chart,
              ),
            )
          ],
        ),
      ),
    );
  }

  String getTime(num sell) {
    double sellmoney = sell;
    for (int i = 0; i < hotLineBean.result.length; i++) {
      if (sellmoney == hotLineBean.result[i].sellHot) {
        return hotLineBean.result[i].hours;
      }
      if (sellmoney == hotLineBean.result[i].supplyHeat) {
        return hotLineBean.result[i].hours;
      }
    }
  }

  void refresh() {
    // time = formatDate(new DateTime.now(),[yyyy,'-',mm,'-',dd ,"  ",HH,":",nn,":",ss]);
//    getWendu();
    getHotUserInfo2();
    listHotUserVo();
    getDayMonthTotalFlowVo();
    getHotUserInfo(id);
    if (MyApplication.loginuserinfo.userInfo.amHotuser == 0) {
      getHotLine();
      // getTaskCount();
    }
    // if (firstrefresh >= 3) {
    //   getHotUserleiji(selectArea['id']);
    // }
  }

  void rebuild() {
    refresh();
    // Rebuild in order to animate views.
  }

  //  扫描二维码
  Future scan() async {
    try {
      // 此处为扫码结果，barcode为二维码的内容
      String barcode = await BarcodeScanner.scan();
      print('扫码结果: ' + barcode);
    } on PlatformException catch (e) {
      if (e.code == BarcodeScanner.CameraAccessDenied) {
        // 未授予APP相机权限
        print('未授予APP相机权限');
      } else {
        // 扫码错误
        print('扫码错误: $e');
      }
    } on FormatException {
      // 进入扫码页面后未扫码就返回
      print('进入扫码页面后未扫码就返回');
    } catch (e) {
      // 扫码错误
      print('扫码错误: $e');
    }
  }

  void getHotLine() async {
    try {
      Response response;
      response = await DioUtils.dio.get(DioUtils.API_PREFIX +
          "/home/page/listTodayFlowChartDto?type=1&nowDate=" +
          formatDate(new DateTime.now(), [yyyy, '-', mm, "-", dd]));
      Map respMap = json.decode(response.data);
      hotLineBean = HotLineBean.fromJson(respMap);
      chartdata = 1;
      setState(() {});
    } catch (e) {
      //  LocalToast.toast(context,msg: "网络错误");
    }
  }

  void getShowToast() async {
    try {
      Response response;
      response = await DioUtils.dio
          .get(DioUtils.API_PREFIX + "/daily/consumption/getMessageInfo");
      Map respMap = json.decode(response.data);
      basebean bb = basebean.fromJson(respMap);
      if (!bb.success) {
        LocalToast.toast(context, msg: bb.message);
      }
    } catch (e) {
      //  LocalToast.toast(context,msg: "网络错误");
    }
  }

  // void getTaskCount() async {
  //   try {
  //     Response response;
  //     response = await DioUtils.dio.get(
  //         DioUtils.API_PREFIX + "/checkTask/checkTaskStatistics?userName="+MyApplication.loginuserinfo.userInfo.username);
  //     Map respMap = json.decode(response.data);
  //     userTaskBean  = UserTaskBean.fromJson(respMap);
  //     totaltask = userTaskBean.result.totalTaskNumber;
  //     successtask = userTaskBean.result.completedTaskNumber;
  //     fitertask = userTaskBean.result.undoneTaskNumber;
  //
  //   } catch (e) {
  //     //  LocalToast.toast(context,msg: "网络错误");
  //   }
  // }

  void getHotUserInfo2() async {
    try {
      Response response;
      if (MyApplication.loginuserinfo.userInfo.amHotuser == 1) {
        response = await DioUtils.dio.get(DioUtils.API_PREFIX +
            "/RegularData/getHotUserInfo?hotUserId=" +
            MyApplication.loginuserinfo.userInfo.hotuserId);
      } else {
        response = await DioUtils.dio
            .get(DioUtils.API_PREFIX + "/RegularData/getHotUserInfo");
      }

      Map respMap = json.decode(response.data);
      basebean base = basebean.fromJson(respMap);

      if (base.code == 0) {
        MyApplication.hotuserbean = hotuserinfobean.fromJson(base.result);
      } else if (base.code == 500) {
        LocalToast.toast(context, msg: "会话超时，请重新登陆！");
        Navigator.pushAndRemoveUntil(
          context,
          new MaterialPageRoute(builder: (context) => new MyHomePage()),
          (route) => route == null,
        );
      } else {
        LocalToast.toast(context, msg: base.message);
      }
    } catch (e) {
      //  LocalToast.toast(context,msg: "网络错误");
      print('请求出错：' + e.toString());
    }
  }

  void getHotUserInfo(String id) async {
    LogUtil.v(id);
    try {
      Response response;
      if (MyApplication.loginuserinfo.userInfo.amHotuser == 1) {
        response = await DioUtils.dio.get(DioUtils.API_PREFIX +
            "/RegularData/getHotUserInfo?hotUserId=" +
            MyApplication.loginuserinfo.userInfo.hotuserId);
      } else {
        response = await DioUtils.dio.get(DioUtils.API_PREFIX +
            "/RegularData/getHotUserInfo?hotUserId=" + id);
      }

      Map respMap = json.decode(response.data);
      basebean base = basebean.fromJson(respMap);
      if (base.code == 0) {
        userinfobean = hotuserinfobean.fromJson(base.result);
        hotusercount = userinfobean.hotUserInfoTotalVo.totalHotUserNum;
        firstrefresh += 1;
        initData(0, 0);
        // initarea =
        //     MyApplication.hotuserbean.lineHotUserInfoTotalVos[0].lineName +
        //         "/" + MyApplication.hotuserbean.lineHotUserInfoTotalVos[0]
        //         .focusHotUserVos[0].fullName;
        setState(() {});
        if (firstrefresh <= 3) {
          getHotUserleiji(MyApplication
              .hotuserbean.lineHotUserInfoTotalVos[0].focusHotUserVos[0].id);
        }
      } else if (base.code == 500) {
        LocalToast.toast(context, msg: "会话超时，请重新登陆！");
        Navigator.pushAndRemoveUntil(
          context,
          new MaterialPageRoute(builder: (context) => new MyHomePage()),
          (route) => route == null,
        );
      } else {
        LocalToast.toast(context, msg: base.message);
      }
    } catch (e) {
      //  LocalToast.toast(context,msg: "网络错误");
      print('请求出错：' + e.toString());
    }
  }

  void getLineAndHotUserTreeVo() async {
    try {
      Response response;
      if (MyApplication.loginuserinfo.userInfo.amHotuser == 1) {
        response = await DioUtils.dio.get(DioUtils.API_PREFIX +
            "/line/getLineAndHotUserTreeVo?type=1&companyName=" +
            MyApplication.loginuserinfo.userInfo.username);
      } else {
        response = await DioUtils.dio
            .get(DioUtils.API_PREFIX + "/line/getLineAndHotUserTreeVo?type=1");
      }

      Map respMap = json.decode(response.data);
      basebean base = basebean.fromJson(respMap);
      if (base.code == 0) {
        // Map map = {
        //   "id": "0",
        //   "name": "所有管道",
        //   "hotUserTreeVos": [
        //     {
        //       "id": "0",
        //       "name": "所有管道",
        //       "price": 1,
        //       "type": 1,
        //     }
        //   ],
        // };
        // List result = respMap["result"];
        // result.insert(0, map);
        var getLineAndHotUserTreeVoBean =
            GetLineAndHotUserTreeVoBean.fromJson(respMap);
        MyApplication.mapRoadChoice3 = respMap;
        //这里是数据
        // if (firstrefresh <= 3) {
        //   getHotUserleiji(0);
        // }
        firstrefresh += 1;

        initarea = getLineAndHotUserTreeVoBean.result[0].name + "/" +
            getLineAndHotUserTreeVoBean.result[0].hotUserTreeVos[0].name;
        id=getLineAndHotUserTreeVoBean.result[0].id;
        getHotUserInfo(getLineAndHotUserTreeVoBean.result[0].id);
        setState(() {});
      } else if (base.code == 500) {
        LocalToast.toast(context, msg: "会话超时，请重新登陆！");
        Navigator.pushAndRemoveUntil(
          context,
          new MaterialPageRoute(builder: (context) => new MyHomePage()),
          (route) => route == null,
        );
      } else {
        LocalToast.toast(context, msg: base.message);
      }
    } catch (e) {
      //  LocalToast.toast(context,msg: "网络错误");
      print('请求出错：' + e.toString());
    }
  }

  void listHotUserVo() async {
    try {
      Response response;
      if (MyApplication.loginuserinfo.userInfo.amHotuser == 0) {
        response = await DioUtils.dio
            .get(DioUtils.API_PREFIX + "/hot/user/listHotUserVo");
      } else {
        response = await DioUtils.dio.get(DioUtils.API_PREFIX +
            "/hot/user/listHotUserVo?hotUserId=" +
            MyApplication.loginuserinfo.userInfo.hotuserId);
      }
      Map respMap = json.decode(response.data);
      MyApplication.alluserlist = userInfoList.fromJson(respMap);
      firstrefresh += 1;
      setState(() {});
    } catch (e) {
      //  LocalToast.toast(context,msg: "网络错误");
      print('请求出错：' + e.toString());
    }
  }

  void getDayMonthTotalFlowVo() async {
    try {
      Response response;
      if (MyApplication.loginuserinfo.userInfo.amHotuser == 0) {
        response = await DioUtils.dio
            .get(DioUtils.API_PREFIX + "/RegularData/getDayMonthTotalFlowVo");
      } else {
        response = await DioUtils.dio.get(DioUtils.API_PREFIX +
            "/RegularData/getDayMonthTotalFlowVo?hotUserId=" +
            MyApplication.loginuserinfo.userInfo.hotuserId);
      }
      Map respMap = json.decode(response.data);
      getDayMonthTotalFlowVoBean = GetDayMonthTotalFlowVoBean.fromJson(respMap);
      firstrefresh += 1;
      setState(() {});
    } catch (e) {
      //  LocalToast.toast(context,msg: "网络错误");
      print('请求出错：' + e.toString());
    }
  }

  hotuserleijiliuliangbean leijibean;

  void getHotUserleiji(var hotuserid) async {
    try {
      Response response;
      response = await DioUtils.dio.get(DioUtils.API_PREFIX +
          "/RegularData/getDayMonthTotalFlowVo?hotUserId=" +
          hotuserid);
      Map respMap = json.decode(response.data);
      leijibean = hotuserleijiliuliangbean.fromJson(respMap);
      firstrefresh += 1;
      setState(() {});
    } catch (e) {
      //  LocalToast.toast(context,msg: "网络错误");
      print('请求出错：' + e.toString());
    }
  }

  void initData(int index1, int index2) {
    gongzuowendu = userinfobean
        .lineHotUserInfoTotalVos[index1].focusHotUserVos[index2].jobTemperature;
    fahouwendu = userinfobean.lineHotUserInfoTotalVos[index1]
        .focusHotUserVos[index2].afterValveTemperature;
    gongzuoyali = userinfobean
        .lineHotUserInfoTotalVos[index1].focusHotUserVos[index2].jobStress;
    diandongfa = userinfobean
        .lineHotUserInfoTotalVos[index1].focusHotUserVos[index2].valveStatus;
    shuju = userinfobean
        .lineHotUserInfoTotalVos[index1].focusHotUserVos[index2].dataStatus;
    tongxun = userinfobean.lineHotUserInfoTotalVos[index1]
        .focusHotUserVos[index2].communicationStatus;
    baojing = userinfobean
        .lineHotUserInfoTotalVos[index1].focusHotUserVos[index2].alarmStatus;
    time = userinfobean
        .lineHotUserInfoTotalVos[index1].focusHotUserVos[index2].newest;
    shunshiliuliang = userinfobean
        .lineHotUserInfoTotalVos[index1].focusHotUserVos[index2].instantFlow;
    leijiliuliang = userinfobean
        .lineHotUserInfoTotalVos[index1].focusHotUserVos[index2].totalFlow;
    shengyuqiliang = userinfobean
        .lineHotUserInfoTotalVos[index1].focusHotUserVos[index2].steam;
  }

// void initData2() {
//   var result = getDayMonthTotalFlowVoBean.result;
// gongzuowendu = result.jobTemperature;
// dayTotalFlow fahouwendu = result.afterValveTemperature;
// gongzuoyali = result.jobStress;
// diandongfa = result.valveStatus;
// shuju = result.dataStatus;
// tongxun = result.communicationStatus;
// baojing = result.alarmStatus;
// time = result.newest;
// shunshiliuliang = result.instantFlow;
// leijiliuliang = result.totalFlow;
// shengyuqiliang = result.steam;
// }
}

class SearchBarDelegate extends SearchDelegate<String> {
  //清空按钮
  @override
  List<Widget> buildActions(BuildContext context) {
    return [
      IconButton(
        icon: Icon(Icons.clear),
        onPressed: () => query = "", //搜索值为空
      )
    ];
  }

  //返回上级按钮
  @override
  Widget buildLeading(BuildContext context) {
    return IconButton(
        icon: AnimatedIcon(
            icon: AnimatedIcons.menu_arrow, progress: transitionAnimation),
        onPressed: () => close(context, null) //点击时关闭整个搜索页面
        );
  }

  //搜到到内容后的展现
  @override
  Widget buildResults(BuildContext context) {
    return Container(
      width: 100.0,
      height: 100.0,
      child: Card(
        color: Colors.redAccent,
        child: Center(
          child: Text(query),
        ),
      ),
    );
  }

  //设置推荐
  @override
  Widget buildSuggestions(BuildContext context) {
    final suggestionsList = query.isEmpty
        ? recentSuggest
        : searchList.where((input) => input.startsWith(query)).toList();

    return ListView.builder(
      itemCount: suggestionsList.length,
      itemBuilder: (context, index) => ListTile(
        title: RichText(
          //富文本
          text: TextSpan(
              text: suggestionsList[index].substring(0, query.length),
              style: TextStyle(
                  color: Colors.black,
                  fontWeight: FontWeight.bold,
                  fontSize: 14),
              children: [
                TextSpan(
                    text: suggestionsList[index].substring(query.length),
                    style: TextStyle(color: Colors.grey))
              ]),
        ),
      ),
    );
  }
}
